/* Author: Pericles Alves [periclesrafael@dcc.ufmg.br] */

#ifndef jsion_abcp_h__
#define jsion_abcp_h__

// This file represents the Arguments Based Constant Propagation optimization pass

namespace js {
namespace ion {

/**
  * Arguments to be propagated as constants
  */
class CPArguments
{
  private:
    StackFrame *fp;
    unsigned nargs;
    Value *args;

  public:
    CPArguments(StackFrame *fp);
    bool extractArgs();
    unsigned numArgs();
    Value *getArg(unsigned i);
};

MInstruction * findFirstInstruction(MBasicBlock *block, int op);
bool Constantify(MIRGraph &graph, CPArguments &arguments, MInstructionIterator parameterIterator);
bool ArgumentConstantification(MIRGraph &graph, StackFrame *fp);
bool initParameters(MIRGraph &graph, CPArguments &arguments);
bool initOsrValues(MIRGraph &graph, CPArguments &arguments);

}
}
#endif // jsion_abcp_h__
